package server;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.util.Random;
import java.io.File;
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.DataOutputStream;

public class ProtocolTest extends TestCase {

    static Random random = new Random();
    static RandomUtils randomUtils = new RandomUtils();

	public ProtocolTest(String name) {
		super(name);
	}

    // Test that the ctor correctly copies the arguments
    public void testCtor() {
        for (int i = 0; i < 300; ++i) {
            long expectedTime = random.nextLong();
            String expectedProtocol = randomUtils.getRandomString(5 + random.nextInt(10));
            String expectedInReg = randomUtils.getRandomString(5 + random.nextInt(10));
            String expectedOutReg = randomUtils.getRandomString(5 + random.nextInt(10));
            Protocol prot = new Protocol(expectedProtocol, expectedInReg, expectedOutReg);

            assertEquals(expectedProtocol, prot.protocol);
            assertEquals(expectedInReg, prot.inReg);
            assertEquals(expectedOutReg, prot.outReg);
        }
    }

	public static Test suite(String[] args) {
		if (args.length == 0) {
			return new TestSuite(ProtocolTest.class);
		} else {
			TestSuite testsToRun = new TestSuite();
			for (int i = 0; i < args.length; ++i) {
				testsToRun.addTest(new ProtocolTest(args[i]));
			}
			return testsToRun;
		}
	}
}
